﻿using IcsSEMCtrl.Util.Client;
using Lifter.Device;
using Lifter.Device.Unit;
using Sunny.UI;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace TKT.Lifter.CIM.Lifter.Gui.Monitor.Popups
{
    public partial class ShuttleDetailInfo : UIForm
    {
        LifterSEM lifterSEM = (LifterSEM)Naming.GetDeviceManager().GetLifter();
        protected override CreateParams CreateParams
        {
            get
            {
                CreateParams cp = base.CreateParams;
                cp.ExStyle |= 0x02000000; // 用双缓冲绘制窗口的所有子控件
                return cp;
            }
        }
        public ShuttleDetailInfo()
        {
            InitializeComponent();
            this.LoadVehicles();
            this.LoadShuttleInfo();
        }
        /// <summary>
        /// 加载轿厢CV信息数据
        /// </summary>
        private void LoadVehicles()
        {
            List<string> vehicles = new List<string>();
            foreach (Vehicle vehicle in lifterSEM.Vehicles.Values)
            {
                vehicles.Add(vehicle.HostID);
            }
            this.cbVehicleBuffer.Items.AddRange(vehicles.ToArray());
        }
        private void LoadShuttleInfo()
        {
            this.tbShuttleTransferStatus.Text = lifterSEM.ShuttleMaster.TransferStatus.ToString();
            this.tbShuttleFloor.Text = lifterSEM.ShuttleMaster.ShuttleFloor.ToString();
            this.tbShuttleDest.Text = lifterSEM.ShuttleMaster.ShuttleDestFloor.ToString();

        }

        private void cbVehicleBuffer_TextChanged(object sender, EventArgs e)
        {
            string vehicleID = this.cbVehicleBuffer.Text;
            if (!string.IsNullOrEmpty(vehicleID))
            {
                Vehicle vehicle = this.lifterSEM.GetVehicle(vehicleID);
                this.tbVehicleSource.Text = vehicle.VehicleSource.ToString();
                this.tbVehicleDest.Text = vehicle.VehicleDest.ToString();
            }
        }
    }
}
